#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QMouseEvent>
#include <QWheelEvent>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    // 显示告诉Qt我们要追踪鼠标位置
    this->setMouseTracking(true);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::mouseMoveEvent(QMouseEvent *event)
{
    // 打印出鼠标的位置
    qDebug() << "鼠标的位置: (" << event->x() << ", " << event->y() << ")";

}

void Widget::wheelEvent(QWheelEvent *event)
{
    qDebug() << "鼠标滚轮滚动的距离: " << event->delta();

}

